package com.ciaojian.client.controller;

import com.ciaojian.client.service.HairArchiveImgServiceImpl;
import com.ciaojian.core.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author oxiny
 */
@Api(tags = "用户模块: 发型档案")
@AllArgsConstructor
@RestController
@RequestMapping("/user/hair-archive/img")
public class HairArchiveImgController {
    private final HairArchiveImgServiceImpl hairArchiveImgService;

    @ApiOperation("查询收藏的图片")
    @GetMapping("/favorite")
    public Result listFavorite(@NotNull Integer userId) {
        return Result.ok(hairArchiveImgService.listFavorite(userId));
    }

    @ApiOperation("收藏图片")
    @PutMapping("/favorite/{id}")
    public Result favorite(@PathVariable Integer id) {
        hairArchiveImgService.favorite(id);
        return Result.ok();
    }

    @ApiOperation("删除图片")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        hairArchiveImgService.removeById(id);
        return Result.ok();
    }
}

